home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Answers 2002 January
/
PC Answers January 2002.7z
/
PC Answers January 2002.bin
/
graphics
/
freepixl
/
_SETUP.1
/
Registry.pxl
< prev
next >
Wrap
Text File
|
1998-02-13
|
8KB
|
277 lines
Initialize:
UseCoordinates(PIXEL)
UseBackGround(TRANSPARENT,192,192,192)
DrawBackGround
WaitInput(100) {let NT and 95 catch up}
InfoMenu(REMOVE)
SetMenu()
Title$ = "Windows 95/NT Registry Commands"
UseCaption(Title$)
WinLocate(Title$,250,10,620,240,Res)
WinShow(Title$,TOPMOST,Res)
DirGet(SourceDir$)
SetMenu("E&xit!",Leave,
ENDPOPUP,
"&Registry",IGNORE,
"&Open PiXCL4.1 Key",Open_Key,
"&Enum PiXCL4.1 Key",Enum_Key,
"&Close PiXCL4.1 Key",Close_Key,
SEPARATOR,
"&Add PiXCL4.1 Key",Create_Key,
"&Delete PiXCL4.1 Key",Delete_Key,
SEPARATOR,
"&Query PiXCL4.1 Key",QueryKey,
"&Query PiXCL4.1 Key Value",QueryValue,
ENDPOPUP,
"&Specific Tests",IGNORE,
"Get Ethernet Address",MAC_Address,
"Num To Hex",ToHex,
"Hex To Num", ToNum,
ENDPOPUP,
"&Help",IGNORE,
"&Information",Info,
"&View PXL source",ViewSource,
SEPARATOR,
"&About",About,
ENDPOPUP)
Wait_for_Input:
WaitInput()
Leave: {clean up after the demo}
RDBDeleteKey(@RDB_CLASSES_ROOT,"PiXCL4.1",Res)
End
ToHex:
DrawBackground
Number = 29987665
DrawNumber(10,10,Number)
NumToHex(Number,HexNum$)
Drawtext(10,30,HexNum$)
Goto Wait_for_Input
ToNum:
DrawBackground
HexNum$ = "0287fdae"
HexToNum(HexNum$,Number,Res)
If Res = 1
DrawNumber(10,10,Number)
Drawtext(10,30,HexNum$)
Else
DrawText(10,10,"HexToNum failed.")
Endif
Goto Wait_for_Input
Info:
MessageBox(OK,1,INFORMATION,
"This sample program shows you how to access the Registry.
We suggest that you look at the PiXCL code first to see
what is displayed as results in the client area. There are
also comments in the PXL source that explain more fully
what is happening.
To use this sample program, you must first create some
entries in the Registry with the 'Create' menu item. Once
entries are created, start up Windows REGEDIT and look in
the HKEY_CLASSES_ROOT for the 'PiXCL4.1' entries.
The 'Open' menu item will now return success. Try the
'Query' menu item and see that the information returned
is the same as you see with REGEDIT.
Please TAKE CARE accessing the Registry: trial and error
changes can result in a corrupted database, and a reload
of all software may be necessary.",
"Using the Registry Access Sample program",Res)
Goto Wait_for_Input
ViewSource:
PXLfile$ = SourceDir$ + "\registry.pxl"
CmdLine$ = "Notepad " + PXLfile$
Run(CmdLine$)
Goto Wait_for_Input
About:
AboutUser("PiXCL 4.1 Sample Program",
"Reading and Writing the Windows Registration Database.",
"This sample program will create, read and delete
specific sample entries for PiXCL 4.1 in the Registry.
No existing entries are accessed or changed.")
Goto Wait_for_Input
Open_Key:
DrawBackground
RDBOpenKey(@RDB_CLASSES_ROOT,"PiXCL4.1",Handle)
DrawNumber(10,10,Handle)
Goto Wait_for_Input
QueryKey:
DrawBackground
RDBQueryKey(Handle,Class$, NumKeys, NumValues, Res)
If Class$ = "" Then Class$ = "Class$ returns NULL"
DrawText(10,10,Class$)
DrawNumber(10,30,NumKeys)
DrawNumber(10,50,NumValues)
Goto Wait_for_Input
QueryValue:
DrawBackground
RDBOpenKey(Handle,"DefaultIcon",IconHandle)
RDBOpenKey(Handle,"Image Formats",FMTHandle)
RDBOpenKey(Handle,"Properties",PtyHandle)
RDBQueryValue(IconHandle,"",Value1$,Res) {gets "(Default)" value string}
RDBQueryValue(IconHandle,"SecondIcon",Value2$,Res) {gets specific value string}
RDBQueryValue(FMTHandle,"Type2",Value3$,Res) {gets specific value}
RDBQueryValue(PtyHandle,"Type1",Value4$,Res) {gets specific value}
DrawText(10,10,Value1$)
DrawText(10,35,Value2$)
DrawText(10,60,Value3$)
DrawText(10,85,Value4$)
Goto Wait_for_Input
Close_Key:
DrawBackground
RDBCloseKey(Handle,Res)
DrawNumber(10,10,Res)
Goto Wait_for_Input
Create_Key:
DrawBackground
RDBCreateKey(@RDB_CLASSES_ROOT,"PiXCL4.1","",Handle,Res)
RDBCreateKey(Handle,"DefaultIcon","",PXL40IconHandle,Res)
{In next, note NULL string, Handle defines location. This will add the
value string to the "(Default)" Handle entry in the registry}
RDBSetValue(PXL40IconHandle,"", "i:\p40tools\pdk\PiXCL41.exe,1",STRING,Res)
RDBSetValue(PXL40IconHandle,"SecondIcon", {note new item in "DefaultIcon" tree}
"i:\p40tools\pdk\PiXCL41.exe,2",STRING,Res)
RDBCreateKey(Handle,"Properties","",PXLPropHandle,Res)
RDBSetValue(PXLPropHandle,"Type1","256",DWORD,Res)
RDBCreateKey(Handle,"Image Formats","",PXLImgHandle,Res)
RDBSetValue(PXLImgHandle,"Type2","BMP|RLE|PNG|JPG|",LIST,Res)
If Res <= 1
DrawNumber(10,10,Handle)
DrawNumber(10,35,Res)
Else
DrawText(10,10,"Entry already exists")
DrawNumber(10,35,Handle)
Endif
Goto Wait_for_Input
Delete_Key:
DrawBackground
RDBDeleteKey(@RDB_CLASSES_ROOT,"PiXCL4.1",Res)
{RDBDeleteKey(Handle,"PiXCL4.1",Res)} {fails, key$ is not subkey of handle}
DrawNumber(10,10,Res)
Goto Wait_for_Input
Enum_Key:
DrawBackground
Index = 0
RDBEnumKey(Handle,0,SubKey$,Class$,Res)
DrawText(10,10,SubKey$)
If Class$ = "" Then Class$ = "Class$ returns NULL"
DrawText(10,30,Class$)
RDBEnumKey(Handle,1,SubKey$,Class$,Res)
DrawText(10,50,SubKey$)
If Class$ = "" Then Class$ = "Class$ returns NULL"
DrawText(10,70,Class$)
RDBEnumKey(Handle,2,SubKey$,Class$,Res)
DrawText(10,90,SubKey$)
If Class$ = "" Then Class$ = "Class$ returns NULL"
DrawText(10,110,Class$)
{This should result in a "no more entries" Result=2}
RDBEnumKey(Handle,3,SubKey$,Class$,Res)
DrawNumber(230,150,Res)
If SubKey$ = "" Then SubKey$ = "SubKey$ returns NULL"
DrawText(25,130,SubKey$)
If Class$ = "" Then Class$ = "Class$ returns NULL"
DrawText(25,150,Class$)
Goto Wait_for_Input
EnumLoop:
RDBEnumKey(Handle,Index,SubKey$,Class$,Res)
DrawBackGround WaitInput(400)
DrawNumber(10,0,Res)
DrawText(10,20,SubKey$)
DrawText(10,40,Class$)
Index = Index + 1
If Res <> 2 Then Goto EnumLoop
Goto Wait_for_Input
MAC_Address:
DrawBackground
Handle = 0
RDBOpenKey(@RDB_Local_Machine,
"SOFTWARE\Description\Microsoft\Rpc\UuidTemporaryData",Handle)
DrawNumber(10,10,Handle)
RDBQueryValue(Handle,"NetworkAddress",MACAddress$,Result)
DrawNumber(10,30,Result) DrawText(25,30,MACAddress$)
RDBCloseKey(Handle,Result)
DrawNumber(10,50,Result)
Goto Wait_for_Input
{
I am trying to retrieve the Ethernet Hardware Address (MAC Address) from
the Win 95 registry. If you have an ethernet card, it is in the
HKEY_LOCAL_MACHINE\SOFTWARE\Description\Microsoft\Rpc\UuidTemporaryData\
NetworkAddress key. The value is 6 hexadecimal bytes long and is stored
in what you call the "LIST token" format. My MAC Address happens to be:
00 a0 24 c6 74 c9. When I use the following piece of code,
RDBOpenKey(@RDB_Local_Machine,"SOFTWARE\Description\Microsoft\Rpc\UuidTe
mporaryData",Handle)
RDBQueryValue(Handle,"NetworkAddress",MACAddress$,Result)
RDBCloseKey(Handle,Result)
MACAddress$ ends up equal to -24576. What I really want is the
MacAddress$ = "00 a0 24 c6 74 c9". I have used the RDBSetValue to
plug a value into the LIST format, but I have not used RDBQueryValue
to retrieve a LIST formatted value (up to now, I have only queried
string values). What does -24576 represent? ANSI numbers, maybe? Do
I need to use some form of ANSI and CHR to pull the hex values out?
}